<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员黑名单管理</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        h1, h2 {
            color: #333;
        }
        .ip-list {
            list-style-type: none;
            padding: 0;
        }
        .ip-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px;
            margin-bottom: 10px;
            background-color: #f5f5f5;
            border-radius: 4px;
        }
        .remove-btn {
            background-color: #ff4d4d;
            color: white;
            border: none;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
        }
        .remove-btn:hover {
            background-color: #cc0000;
        }
        .back-link {
            display: inline-block;
            margin-top: 20px;
            padding: 10px 15px;
            background-color: #4CAF50;
            color: white;
            text-decoration: none;
            border-radius: 4px;
        }
        .back-link:hover {
            background-color: #45a049;
        }
        .no-ips {
            text-align: center;
            padding: 20px;
            background-color: #e7f3fe;
            border-radius: 4px;
        }
    </style>
</head>
<body>
    <h1>管理员黑名单管理</h1>

    {% with messages = get_flashed_messages() %}
        {% if messages %}
            <ul class="flashes">
                {% for message in messages %}
                    <li>{{ message }}</li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endwith %}

    <h2>当前黑名单IP</h2>
    {% if blacklisted_ips %}
        <ul class="ip-list">
            {% for ip in blacklisted_ips %}
                <li class="ip-item">
                    {{ ip }}
                    <form action="{{ url_for('remove_blacklist', ip=ip) }}" method="post" style="display: inline;">
                        <button type="submit" class="remove-btn" onclick="return confirm('确定要移除这个IP吗？');">移除</button>
                    </form>
                </li>
            {% endfor %}
        </ul>
    {% else %}
        <div class="no-ips">没有被黑名单的IP</div>
    {% endif %}

    <a href="{{ url_for('admin_dashboard') }}" class="back-link">返回管理员仪表板</a>
</body>
</html>